/*!
 * Copyright (C) 2020 - All Rights Reserved by
 * @author : ZhaoYanbo
 * @email  : zyb920@hotmail.com
 * @created: 2020-10-31
 * @version: 1.0.0.0
 *
 */

#include "le_scrollarea.h"
#include "lyriceditwidget.h"
#include <QResizeEvent>
#include <QtDebug>

LE_ScrollArea::LE_ScrollArea(QWidget *parent) : QScrollArea(parent)
{

}

void LE_ScrollArea::resizeEvent(QResizeEvent *e)
{
#if 1
    QWidget *wPtr = this->widget();
    LyricEditWidget *le_w = dynamic_cast<LyricEditWidget *>( wPtr );
    if(le_w)
    {
        int w = e->size().width();
        int h = this->viewport()->height();
        bool pressed = le_w->pressed();
        if(pressed)//移动过程中
        {
            le_w->resize(le_w->width(), h);
        }
        else
        {
            int minw = wPtr->property("min_w").toInt();
            if(w > minw)
            {
                wPtr->resize(w, h );
            }
            else if(minw != wPtr->width() || h != wPtr->height())
            {
                wPtr->resize(minw, h );
            }
        }
    }
#endif
    QScrollArea::resizeEvent(e);
}
